package com.example.cslp.service.Impl;


import com.example.cslp.pojo.entity.Mail;
import com.example.cslp.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class MailServiceImpl implements MailService {
    @Autowired
    private JavaMailSender javaMailSender;
    public void sendSimpleMailMessage(Mail mail){
        System.out.println(mail);
        //封装smm对象
        SimpleMailMessage simpleMailMessage=new SimpleMailMessage();
        simpleMailMessage.setFrom(mail.getSendFrom());
        simpleMailMessage.setTo(mail.getSendTo());
        simpleMailMessage.setCc((mail.getCc()));
        simpleMailMessage.setSubject(mail.getTitle());
        simpleMailMessage.setText(mail.getMessage());
        javaMailSender.send(simpleMailMessage);
    }
}